import org.apache.ignite.internal.util.IgniteUtils;
import org.junit.Test;

import java.sql.*;

/**
 * @author dinghao
 * @create 2021-09-18 16:08
 * @message
 */
public class KBDBTest {
    @Test
    public void test1() {
        Connection conn = null;
        Statement stmt = null;

        String JDBC_DRIVER = "org.postgresql.Driver";
        String DB_URL = "jdbc:postgresql://192.168.1.190:5432/postgre";
        String USER = "postgre";
        String PWD = "postgre";

        try {
            //注册加载jdbc驱动
            Class.forName(JDBC_DRIVER);
            //打开连接
            conn = DriverManager.getConnection(DB_URL,USER,PWD);
            //创建执行对象
            stmt = conn.createStatement();
            String testUrl = "select * from DH.DH2";
            //执行sql语句
            ResultSet rs = stmt.executeQuery(testUrl);
            //ResultSetMetaData rsmd = rs.getMetaData();
            //展开结果集
            while (rs.next()) {
                System.out.println(rs.getString(1));
            }
            rs.close();
            stmt.close();
            conn.close();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
